using System.Collections.Generic;
using Headsight.BPMN2WF.BPMN.Model;
using Headsight.BPMN2WF.Transformation.Transformers.Additions;

namespace Headsight.BPMN2WF.Transformation.BPMN2TransformerMappings.Additions
{
    /// <summary>
    /// <see cref="IBPMN2WFTransformations"/> implementation
    /// wrapping the <see cref="IBPMN2WFTransformation"/>s returned
    /// by the passed in <see cref="IBPMN2WFTransformations"/> delegate
    /// into a singleton instance of <see cref="BPMN2WFTransformationCache"/>. 
    /// </summary>
    public class BPMN2WFTransformationsCacheWrapper : BPMN2WFTransformationsDelegateBaseImpl
    {
        public BPMN2WFTransformationsCacheWrapper(IBPMN2WFTransformations @delegate) : base(@delegate)
        {
            Cache = new Dictionary<BPMNFlowNode, BPMNTransformationResult>();
        }

        public IDictionary<BPMNFlowNode, BPMNTransformationResult> Cache { get; private set; }

        public override IBPMN2WFTransformation Get(BPMNFlowNode flowNode)
        {
            return new BPMN2WFTransformationCache(Cache, Delegate.Get(flowNode));
        }
    }
}